[main][cherry-pick] Fix(curl): surface auth errors and avoid panic on nil HTTP response - #3839
Open
prkalle wants to merge 1 commit into
Open
[main][cherry-pick] Fix(curl): surface auth errors and avoid panic on nil HTTP response#3839prkalle wants to merge 1 commit into
prkalle wants to merge 1 commit into
Conversation
MakeCurlRequest assumed that a non-nil error always came with an HTTP response (e.g. a 4xx/5xx from the API). That assumption breaks when the request fails before reaching the API — for example a token refresh / client-credentials authentication failure in the UAA request wrapper, which returns an error with a nil *http.Response. In that case: - Without --fail, the error was swallowed and cf curl printed empty output, giving the user no indication anything went wrong. - With --fail, the code dereferenced httpResponse.StatusCode on the nil response and panicked. Only surface CurlExit22Error when an HTTP response is actually present; when the response is nil, return the underlying error directly so the user sees a real message (e.g. "Bad credentials") and cf curl exits cleanly instead of panicking. Existing behavior for real HTTP error responses (print body by default, fail only with --fail) is unchanged. Signed-off-by: Prem Kumar Kalle <prem.kalle@broadcom.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
This PR fixes
cf curlcommand to surface auth errors and avoid panic on nil HTTP responseThis PR is cherry-pick of #3838
Why Is This PR Valuable?
Thiis fixes the panic and surfaces underlying auth errors to users so the user sees a real message (e.g. "Bad credentials")
Applicable Issues
List any applicable GitHub Issues here
How Urgent Is The Change?
Medium
Other Relevant Parties
Who else is affected by the change?